# -*- coding: utf-8 -*-
# @Time : 2022/2/25 17:27
# @File : forms.py

from django import forms
from .models import RootModel
from django.forms import widgets
from login_system import models


class RootForm(forms.ModelForm):
    verifycode = forms.CharField(
        widget=widgets.TextInput(attrs={'class': 'form-control', 'placeholder': 'verify code'}),
        max_length=5)

    password = forms.CharField(
        widget=widgets.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'password'}),
        max_length=16
    )

    class Meta:
        model = RootModel
        fields = "__all__"
        widgets = {
            'username': widgets.TextInput(attrs={'class': 'form-control', 'placeholder': 'username'}),
        }


class adduser(forms.ModelForm):
    class Meta:
        model = models.User
        fields = ['username', 'identity_c', 'name', 'age', 'tel', 'driving_license_type', 'password']
        widgets = {
            'username': widgets.TextInput(attrs={'class': 'form-control', 'placeholder': 'username'}),
            'identity_c': widgets.HiddenInput(attrs={'class': 'form-control', }),
            'name': widgets.TextInput(attrs={'class': 'form-control', 'placeholder': 'name'}),
            'age': widgets.NumberInput(attrs={'class': 'form-control', 'placeholder': 'age'}),
            'tel': widgets.NumberInput(attrs={'class': 'form-control', 'placeholder': 'tel'}),
            'driving_license_type': widgets.Select(attrs={'class': 'form-control'}),
            'password': widgets.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'password'})
        }
